<template>
  <div class="cinema">

    <!-- 下拉菜单 -->
    <div>
      <van-dropdown-menu>
        <van-dropdown-item title="全城" v-model="value2" :options="option2">
          <div class="all-city">
            <van-tabs
              v-model="active"
              title-active-color="#dd403b"
              title-inactive-color="#222"
              line-width="60px"
            >
              <van-tab title="商圈">
                <div class="area-box">
                  <van-sidebar v-model="activeKey" class="fl">
                    <div v-for="(disItem, index) in districtData" :key="index">
                      <van-sidebar-item :title="disItem.name" />
                      <div class="cinema-num">
                        <span>{{ disItem.count }}</span>
                        <van-icon name="arrow" />
                      </div>
                    </div>
                  </van-sidebar>
                </div>
              </van-tab>
              <van-tab title="地铁站">
                <div class="area-box">
                  <van-sidebar v-model="activeKey">
                    <div v-for="(subwayItem, index) in subwayData" :key="index">
                      <van-sidebar-item :title="subwayItem.name" />
                      <div class="cinema-num">
                        <span>{{ subwayItem.count }}</span>
                        <van-icon name="arrow" />
                      </div>
                    </div>
                  </van-sidebar>
                </div>
              </van-tab>
            </van-tabs>
          </div>
        </van-dropdown-item>

        <van-dropdown-item title="品牌" v-model="value1" :options="option1">
          <ul class="brand-list">
            <li v-for="(brandItem, index) in brandData" :key="index">
              <div class="brand-name">{{ brandItem.name }}</div>
              <div class="brand-num">{{ brandItem.count }}</div>
            </li>
          </ul>
        </van-dropdown-item>
        <van-dropdown-item title="特色" v-model="value3" :options="option3">
          <div class="cinema-service">
            <div class="service-title">影院服务</div>
            <div class="service-box">
              <van-button
                plain
                class="one-text"
                v-for="(serItem, index) in serviceData"
                :key="index"
              >
                {{ serItem.name }}
              </van-button>
            </div>

            <div class="service-type">影厅类型</div>
            <div class="type-box">
              <van-button
                plain
                class="type-button one-text"
                v-for="(typeItem, index) in hallTypeData"
                :key="index"
              >
                {{ typeItem.name }}
              </van-button>
            </div>

            <div class="service-bottom">
              <van-button plain>重置</van-button>
              <van-button plain>完成</van-button>
            </div>
          </div>
        </van-dropdown-item>
      </van-dropdown-menu>
    </div>

    <!-- 影院列表 -->
    <div class="cinema-box">
      <ul class="cinema-list">
        <li v-for="(listItem, index) in cinemaListData" :key="index"
        @click="goCinemaDetail(listItem.cinemaId)">
          <div class="cinema-list-top clearfix">
            <div class="cinema-name one-text fl">{{ listItem.title }}</div>
            <div class="cinema-price fr">
              <span class="price">{{ listItem.price.n }}</span
              >{{ listItem.price.q }}
            </div>
          </div>
          <div class="cinema-list-center clearfix">
            <div class="cinema-position fl one-text">
              {{ listItem.location }}
            </div>
            <div class="cinema-distance fr">{{ listItem.distance }}</div>
          </div>
          <div class="cinema-list-bottom">
            <div
              class="change"
              v-for="(serviceItem, index) in listItem.services"
              :key="index"
            >
              {{ serviceItem.text }}
            </div>
          </div>
          <div class="quan" v-for="(discountItem,index) in listItem.discount" :key="index">
            <!-- <div class="quan-tag">券</div> -->
            <img :src="discountItem.card" alt="">
            <span class="quan-txt">{{discountItem.text}}</span>
          </div>
          <!-- <div class="ka">
            <div class="ka-tag">卡</div>
            <span class="ka-txt">开卡特惠，首单1涨票最高立领6元起</span>
          </div> -->
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import {mapState} from 'vuex';
export default {
  name: "Cinema",
  data() {
    return {
      active: 0,
      activeKey: 0,
      activeIndex: 0,

      value1: 0,
      value2: 0,
      value3: 0,
      option1: [],
      option2: [],
      option3: [],

      // 品牌数据
      brandData: [],
      // 行政区影院数据
      districtData: [],
      // 地铁线影院数据
      subwayData: [],
      // 影厅类型数据
      hallTypeData: [],
      // 影院服务数据
      serviceData: [],
      cinemaListData: [],
    };
  },
  computed:{
    // ...mapState(['cityId'])
  },
  created() {
    this.filterCinemas();
    this.CinemaList();
  },
  methods: {
    // 获取影院分类数据 全城 品牌 特色
    filterCinemas() {

      // 
      this.axios({
        method: "get",
        url: "/index/filterCinemas",
        params: {
          ci: this.$store.state.cityId
        },
      })
        .then((result) => {
          
          

          // 获取品牌数据
          this.brandData = result.data.brand.subItems;
          // 

          // 获取行政区的影院数据
          this.districtData = result.data.district.subItems;
          // 

          // 获取地铁线的影院数据
          this.subwayData = result.data.subway.subItems;
          // 

          // 获取影厅类型数据
          this.hallTypeData = result.data.hallType.subItems;
          // 

          // 获取影院服务数据
          this.serviceData = result.data.service.subItems;
          // 
        })
        .catch((err) => {
          
        });
    },

    // 获取附近影院列表
    CinemaList() {
      let currentDate = new Date();
      // 
      let year = currentDate.getFullYear() + "-";
      let month =
        (currentDate.getMonth() + 1 < 10
          ? "0" + (currentDate.getMonth() + 1)
          : currentDate.getMonth() + 1) + "-";
      let date =
        currentDate.getDate() < 10
          ? "0" + currentDate.getDate()
          : currentDate.getDate();
      let newDate = year + month + date;
      // 
      

      this.axios({
        method: "get",
        url: "/index/moreCinemas",
        // url: `/index/moreCinemas?day=${newDate}&cityId=${this.$store.state.cityId}$offset=0&limit=10&districtId=-1&hallType=-1&brandId=-1&serviceId=-1`,
        query: {
          day: newDate,
          cityId: this.$store.state.cityId,
          offset: 0,
          limit: 10,
          districtId: -1,
          hallType: -1,
          brandId: -1,
          serviceId: -1,
        },
      })
        .then((result) => {
          
          
          this.cinemaListData = result.data;
          // 
        })
        .catch((err) => {
          
        });
    },

    // 跳转到影院详情
    goCinemaDetail(cinemaId){
      this.$router.push({name:'CinemaDetail',params:{cinemaId}});
      this.$store.commit('getCinemaId',cinemaId)
    }
  },

  
};
</script>

<style lang="less" scoped>
.cinema {
  margin-top: 50px;
}
.swipe-box {
  // border: 1px solid #000;
  height: 100px;
  .my-swipe .van-swipe-item {
    height: 100px;
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
  }
}
/deep/ .van-dropdown-menu {
  position: fixed;
  top: 50px;
  left: 0px;
  width: 100%;
}
.area-box {
  // border: 1px solid #000;
  position: relative;
  /deep/.van-tab__text {
    font-size: 15px;
  }
  .van-sidebar {
    // border: 1px solid #000;
    width: 150px;
    font-size: 20px;
  }
  /deep/ .van-sidebar-item {
    // border: 1px solid #000;
    display: flex;
    align-items: center;
  }
  /deep/ .van-sidebar-item__text {
    font-size: 15px;
    // width: 80px;
    // border: 1px solid #000;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .van-sidebar-item--select::before {
    content: "";
    width: 0;
    height: 0;
  }

  .cinema-num {
    // background-color: skyblue;
    position: relative;
    width: 50px;
    height: 0;
    top: -38px;
    left: 100px;
    text-align: center;
    font-size: 14px;
    color: #a7a7a7;
  }
}

.brand-list li {
  height: 42px;
  // border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  .brand-name {
    font-size: 16px;
    color: #222;
  }
  .brand-num {
    font-size: 16px;
    color: #9b9b9b;
  }
}
.cinema-service {
  padding: 12px;
  .service-title {
    font-size: 16px;
    margin-bottom: 12px;
    color: #323232;
  }
  .service-box {
    // border: 1px solid #000;
    .van-button {
      width: 75px;
      height: 35px;
      border: 1px solid #ccc;
      margin-right: 15px;
    }
  }

  .active {
    border: 1px solid #e4393c;
    background-color: #f1f1f1;
    color: #e4393c;
  }
  .service-type {
    font-size: 16px;
    margin-top: 14px;
    margin-bottom: 12px;
  }
  .type-box {
    // border: 1px solid #000;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .type-button {
      width: 75px;
      height: 35px;
      margin-bottom: 10px;
      padding: 0;
      border: 1px solid #ccc;
      .van-button__text {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
    }
  }
  .service-bottom {
    border-top: 1px solid #ddd;
    margin-top: 16px;
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    .van-button {
      width: 70px;
      height: 36px;
      &:first-child {
        border: 1px solid #eee;
      }
      &:last-child {
        background-color: #dd403b;
        color: #fff;
        border: none;
      }
    }
  }
}
.cinema-box {
  // border: 1px solid #00f;
  margin-bottom: 50px;
  margin-top: 100px;
  .cinema-list li {
    border-top: 1px solid #ccc;
    margin-top: 1px solid #f1f1f1;
    padding: 16px;
    .cinema-name {
      width: 280px;
      font-size: 18px;
      font-weight: bold;
    }
    .cinema-price {
      margin-top: 4px;
      color: #aaa;
      .price {
        color: #dd403b;
        font-size: 16px;
      }
    }
    .cinema-list-center {
      margin-top: 10px;
      margin-bottom: 10px;
      .cinema-position {
        font-size: 14px;
        color: #aaa;
        width: 255px;
      }
      .cinema-distance {
        font-size: 14px;
        color: #ccc;
      }
    }
    .cinema-list-bottom {
      // border: 1px solid #000;
      width: 100%;
      display: flex;
      flex-wrap: wrap;

      .change {

        border: 1px solid #1989fa;
        color: #1989fa;
        margin-right: 6px;
        margin-bottom: 4px;
        padding: 2px 4px;
        border-radius: 2px;
      }
      .snack,
      .discount {
        border: 1px solid #ffa500;
        color: #ffa500;
        margin-right: 6px;
        padding: 2px 4px;
        border-radius: 2px;
      }
    }

    .quan {
      margin-top: 12px;
      display: flex;
      align-items: center;
      .quan-tag {
        background-color: #04c6ae;
        color: #fff;
        padding: 3px 6px;
        border-radius: 4px;
        margin-right: 6px;
      }
      .quan-txt {
        font-size: 13px;
        color: #aaa;
      }
      img{
        width: 18px;
        height: 18px;
        margin-right: 4px;
      }
    }
    .ka {
      margin-top: 10px;
      display: flex;
      align-items: center;
      .ka-tag {
        background-color: #ab79e1;
        color: #fff;
        padding: 3px 6px;
        border-radius: 4px;
        margin-right: 6px;
      }
      .ka-txt {
        font-size: 13px;
        color: #aaa;
      }
    }
  }
}
</style>